package cn.kxm.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.kxm.dao.OfferBillDetailMapper;
import cn.kxm.pojo.Sysuser;
import cn.kxm.service.UserService;

import com.alibaba.fastjson.JSON;

@Controller
@RequestMapping("user")
public class TestController{
	@Autowired
	private UserService userService;
	
	@RequestMapping("login")
	@ResponseBody
	public Object login(String name,String pwd,HttpSession session){
		Map<String, String> map=new HashMap<String, String>();
		System.out.println(name+">>>>"+pwd);
		Sysuser user=userService.getUser(name, pwd);
		if(user!=null){
			map.put("result", "success");
			session.setAttribute("user", user);
		}else {
			map.put("result", "error");
		}
		return JSON.toJSONString(map);
	}
	
	@RequestMapping("test")
	@ResponseBody
	public Object login(){
		Map<String, Object> map=new HashMap<String, Object>();
		map.put("result", "aaa");
		return JSON.toJSONString(map);
	}
	@Autowired
	private OfferBillDetailMapper obdm;
	@RequestMapping("testSelectMap")
	public String testSelectMap(){
		List<Map<String, String>> list=obdm.findDetailByBillCode("BJ20181010110004");
		System.out.println(list);
		return "test";
	}
	
}
